import Vue from 'vue'
import Router from 'vue-router'

const routes = [
  {
    path: '/',
    component: () => import('@/sa-resources/index/sa-index.vue'),
    children:[
      {
        path: 'user',
        component: () => import('@/sa-view/user/user-list.vue'),
        name: 'user',
        meta: {title: '用户管理'}
      }
    ]
  },

];

// 路由配置
const RouterConfig = {
  mode: 'history', // require service support
  scrollBehavior: () => ({
    y: 0
  }),
  routes
};

//防止重复点击
const originalPush = Router.prototype.push
Router.prototype.push = function push(location) {
  //console.log(location);
  return originalPush.call(this, location).catch(err => err)
};

// export const router = new Router(RouterConfig)
const createRouter = () => new Router(RouterConfig)

// 创建路由实例
const router = createRouter()

// 添加动态路由
// addAsyncRouter()

export default router;

